package com.example.demo.mapper;

import com.example.demo.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BlogInfoMapper {
    /*
    返回博客列表
     */
    @Select("select * from blog where delete_flag=0")
    List<BlogInfo> querySelectAll();

    /*
        根据id返回博客信息
     */
    @Select("select * from blog where id=#{id}")
    BlogInfo querySelectById(Integer id);



    /*
    根据id物理删除博客
     */
    @Update("update blog set delete_flag=1 where id=#{id}")
    Integer queryDeleteById(Integer id);


    /*
    修改博客信息
     */
    Integer queryUpdate(BlogInfo blogInfo);

    /*
    添加博客
     */
    @Insert("insert into blog (title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);
    @Select("select * from blog where id=#{id}")
    BlogInfo selectById(Integer blogId);
    @Select("select * from blog where id=#{blogId}")
    BlogInfo getBlogById(Integer blogId);
}
